Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
The faker npm package is a powerful tool for generating massive amounts of fake data in Node.js and the browser. It is commonly used for testing, bootstrapping databases, and creating realistic-looking UI prototypes. Faker can generate data for various categories, including names, addresses, phone numbers, dates, and more.
Generating Names
Generates a random full name. Useful for creating user profiles or contact lists in testing environments.
faker.name.findName();
Generating Addresses
Produces a random street address. This can be used to test address forms or display sample addresses on a map.
faker.address.streetAddress();
Generating Internet-related Information
Creates a random email address. Ideal for testing email validation or populating a database with unique user emails.
faker.internet.email();
Generating Lorem Ipsum Text
Generates random 'Lorem Ipsum' text. This is particularly useful for designers and developers who want to fill their layouts with placeholder text to check text formatting and layouts.
faker.lorem.paragraphs();
Generating Random Numbers
Generates a random number within a specified range. This can be used for creating randomized data points for testing calculations or generating mock analytics data.
faker.random.number({ min: 1, max: 100 });
Chance is a minimalist generator of random strings, numbers, etc. to help reduce some monotony particularly while writing automated tests or anywhere else you need anything random. It is somewhat similar to faker but with a focus on simplicity and smaller size.
Casual is a fake data generator for JavaScript that aims to provide an easy way to generate random data for various types of information, similar to faker. It differentiates itself with a more straightforward API and the ability to define custom generators.
Mockaroo is not an npm package but a web service that allows you to generate large datasets of fake data for testing and development. Unlike faker, which is a library you integrate into your code, Mockaroo is used via its website or API to create data based on your specifications.
https://rawgit.com/Marak/faker.js/master/examples/browser/index.html
Don't have a local development setup ready?
Try our hosted version of Faker at https://fakercloud.com/api
https://github.com/faker/faker-cloud
<script src = "faker.js" type = "text/javascript"></script>
<script>
var randomName = faker.name.findName(); // Caitlyn Kerluke
var randomEmail = faker.internet.email(); // Rusty@arne.info
var randomCard = faker.helpers.createCard(); // random contact card containing many properties
</script>
var faker = require('faker');
var randomName = faker.name.findName(); // Rowan Nikolaus
var randomEmail = faker.internet.email(); // Kassandra.Haley@erich.biz
var randomCard = faker.helpers.createCard(); // random contact card containing many properties
http://marak.github.io/faker.js/
faker.js contains a super useful generator method Faker.fake
for combining faker API methods using a mustache string format.
Example:
console.log(faker.fake("{{name.lastName}}, {{name.firstName}} {{name.suffix}}"));
// outputs: "Marks, Dean Sr."
This will interpolate the format string with the value of methods name.lastName()
, name.firstName()
, and name.suffix()
As of version v2.0.0
faker.js has support for multiple localities.
The default language locale is set to English.
Setting a new locale is simple:
// sets locale to de
faker.locale = "de";
faker.js supports incremental loading of locales.
By default, requiring faker
will include all locale data.
In a production environment, you may only want to include the locale data for a specific set of locales.
// loads only de locale
var faker = require('faker/locale/de');
If you want consistent results, you can set your own seed:
faker.seed(123);
var firstRandom = faker.datatype.number();
// Setting the seed again resets the sequence.
faker.seed(123);
var secondRandom = faker.datatype.number();
console.log(firstRandom === secondRandom);
npm install .
make test
You can view a code coverage report generated in coverage/lcov-report/index.html.
faker uses gulp to automate its build process. Each build operation is a separate task which can be run independently.
npm run browser
JSDOC v3 HTML API documentation
npm run jsdoc
The ReadMe.md
file for faker.js
is automatically generated and should not be modified directly. All updates to ReadMe.md
should be performed in ./build/src/docs.md
and then the build script should be run.
npm run readme
faker.js is a popular project used by many organizations and individuals in production settings. Major and Minor version releases are generally on a monthly schedule. Bugs fixes are addressed by severity and fixed as soon as possible.
If you require the absolute latest version of faker.js
the master
branch @ http://github.com/marak/faker.js/ should always be up to date and working.
faker.js - Copyright (c) 2020 Marak Squires www.marak.com http://github.com/marak/faker.js/
faker.js was inspired by and has used data definitions from:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Support us with a monthly donation and help us continue our activities. [Become a backer]
Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]
FAQs
Generate massive amounts of fake contextual data
We found that faker demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.